package com.newgrand.utils.i8util;

import com.newgrand.model.I8ReturnModel;

/**
 * @author ZhaoFengjie
 * @version 1.0
 * @date 2022/8/11 16:42
 */
public class I8ResultUtil {

    public I8ResultUtil() {
    }

    public static I8ReturnModel success() {
        return success("调用成功");
    }

    public static <T> I8Result<T> success(T data) {
        I8Result<T> dateResult = new I8Result();
        dateResult.setCode("0");
        dateResult.setIsOk(true);
        dateResult.setErrorCode("S");
        dateResult.setMessage(data.toString());
        return dateResult;
    }

    public static I8ReturnModel error() {
        return error("调用失败");
    }

    public static <T> I8Result<T> error(T data) {
        I8Result<T> dateResult = new I8Result();
        dateResult.setCode("1");
        dateResult.setIsOk(false);
        dateResult.setErrorCode("E");
        dateResult.setMessage(data.toString());
        return dateResult;
    }
}
